<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<title>修改角色</title>
		
		<base href="<%=basePath%>">
		<link rel="stylesheet" href="css/bootstrap.css">
		<link rel="stylesheet" href="css/vivo.css">
		<link rel="stylesheet" href="css/cmxform.css">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<link rel="stylesheet" href="js/grid/bsgrid.all.min.css" />
		<link rel="stylesheet" type="text/css" href="js/Hui-iconfont/1.0.7/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="js/icheck/icheck.css" />
	
		
		<script src="js/jquery-1.11.1.js"></script>
		<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
		<script src="js/select2/select2.min.js"></script>
		<script src="js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
		<script src="js/jquery.validation/1.14.0/messages_zh.min.js"></script>
		<script type="text/javascript" src="js/sharefunction.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>

		<style type="text/css">
			.primary-vdd {
				color: #fff;
				background-color: #5a98de;
				border-color: #5a98de
			}
			
			.primary-vdd:hover {
				color: #fff;
				background-color: #0a6999;
				border-color: #0a6999
			}
		</style>
		<script type="text/javascript">
			$.validator.setDefaults({
				submitHandler : function() {
					saveDocument();
				}
			});
		
			$(document).ready(function() {
				$("#adminState").select2({
					minimumResultsForSearch : -1
				});
				
				$("#adminState").val(${requestScope.role.adminState}).trigger('change');
				
				$("#commentForm").validate({
					errorPlacement : function(error, element) {
						// Append error within linked label
						$(element).next().append(error);
					},
					errorElement : "span",
					rules : {
						reading : {
							maxlength : 9,
							max : 999999,
							min : 0
						}
					}
		
				});
			});
		
			//存盘数据
			function saveDocument() {
				var id = $("#id").val();
				var roleName = $("#roleName").val();
				var adminState = $("#adminState").val();
				var roleDesc = $("#roleDesc").val();
				var url = "admin/org/role/edit";
				jQuery.ajax({
					type : "post",
					async : false,
					url : url,
					dataType : "json",
					data : {
						id : id,
						roleName : roleName,
						adminState : adminState,
						roleDesc : roleDesc
					},
					success : function(data) {
						if (data.msg=="编辑成功") {
							alert(data.msg);
							location.href="/pms/admin/org/role/list";
						} else {
							alert(data.msg);
						}
					}
				});
			}
		</script>
	
	</head>
	<body>
		<form class="cmxform" id="commentForm" method="post">
			<div style="padding: 20px">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h5 class="panel-title">角色信息</h5>
					</div>
					<div class="panel-body">
						<table cellpadding="10" cellspacing="5" class="mytable">
							
							<tr>
								<td width="90">角色名称</td>
								<td>
									<input type="text" name="roleName" id="roleName" required value="${requestScope.role.roleName }" />
									<font color="red"> *</font>
									<span style="color: red"></span>
								</td>
							</tr>
							<tr>
								<td>角色状态</td>
								<td>
									<select id="adminState" style="width: 90px;">
										<option value="0">普通组角色</option>
										<option value="1">管理组角色</option>
									</select>
								</td>
							</tr>
							<tr>
								<td>角色说明</td>
								<td>
									<textarea name="roleDesc" id="roleDesc" rows="5" cols="100" >${requestScope.role.roleDesc }</textarea>
								</td>
							</tr>
						</table>
					</div>
				</div>
				<div style="width: 100%; text-align: center; padding-top: 20px">
					<button class="btn btn-primary radius primary-vdd" type="submit">保 存</button>
					<a class="btn btn-default radius" onClick="closeLayer();"> 取 消 </a>
					<br />
					<br />
				</div>
			</div>
	
			<div style="display:none">
				<input id="id" name="id" type="hidden" value="${requestScope.role.id }" />
			</div>
		</form>
	</body>
</html>

